package cn.zebra.dev.sys.module.city.service.impl;

import cn.zebra.dev.ibatis.plus.service.impl.ServiceImpl;
import cn.zebra.dev.sys.module.city.dao.SysCityDao;
import cn.zebra.dev.sys.module.city.entity.SysCityEntity;
import cn.zebra.dev.sys.module.city.service.SysCityService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;

import java.util.Collection;

/**
 * @author runnable@sina.cn
 */
@Service
public class SysCityServiceImpl extends ServiceImpl<SysCityDao, SysCityEntity> implements SysCityService {
    @Override
    public Collection<SysCityEntity> getProvincialList() {
        LambdaQueryWrapper<SysCityEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.select(SysCityEntity::getId, SysCityEntity::getCityName);
        wrapper.eq(SysCityEntity::getParentId, 0L);
        return list(wrapper);
    }

    @Override
    public Collection<SysCityEntity> findListByParentId(Long parentId) {
        LambdaQueryWrapper<SysCityEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.select(SysCityEntity::getId, SysCityEntity::getCityName);
        wrapper.eq(SysCityEntity::getParentId, parentId);
        return list(wrapper);
    }
}
